package com.yy.watchmen.utils

import java.io.BufferedReader
import java.io.InputStreamReader

object AdbUtils {
    fun executeAdbCommand(vararg command: String): String? {
        try {
            val processBuilder = ProcessBuilder(*command)
            processBuilder.redirectErrorStream(true)
            val process = processBuilder.start()
            val reader = BufferedReader(InputStreamReader(process.inputStream))
            val output = StringBuilder()
            var line: String?
            while (reader.readLine().also { line = it } != null) {
                output.append(line).append("\n")
            }
            process.waitFor()
            return output.toString()
        } catch (e: Exception) {

        }
        return null
    }
}
